package com.fireant.ommonadapter.sample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.fireant.ommonadapter.CommonRecycleViewAdapter;
import com.fireant.ommonadapter.R;
import com.fireant.ommonadapter.RecyclerViewViewHolder;
import com.fireant.ommonadapter.sample.bean.News;

/**
 * Created by zhangdeyi on 15/9/21.
 */
public class RecylerViewSampleActivity extends AppCompatActivity {

    private RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recylerviewadapter_sample);
        recyclerView = (RecyclerView) findViewById(R.id.recyleView);

        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(layoutManager);

        CommonRecycleViewAdapter<News> adapter = new CommonRecycleViewAdapter<News>(this, R.layout.list_cell_news) {
            @Override
            protected void conver(RecyclerViewViewHolder vh, News data) {
                vh.setText(R.id.tv_title, data.getTitle())
                        .setText(R.id.tv_content, data.getContent());
            }
        };
        recyclerView.setAdapter(adapter);

        adapter.addItem(new News("iOS使用一个MVC替代Brigade’s Experience", "http://www.devtf.cn/"));
        adapter.addItem(new News("React Navtive框架教程", ""));
        adapter.addItem(new News("在Android Lollipop中使用Palette抽取Bitmap颜色", ""));
        adapter.addItem(new News("Android主题动态切换开源库Prism基本原理1-核心功能", ""));
        adapter.addItem(new News("对不起！我来晚了！——《Android群英传》出版祭", ""));
    }
}
